<template>
  <div class="risk">
    <div class="add" @click="add()">创建巡检路线</div>
    <eagle-page-list
      ref="eaglePageList"
      @bindData="bindData"
      :queryParams="queryParams"
      :controller="controller"
      :conditions="conditions"
      :pageSize="20"
    >
      <template slot="list">
        <eagle-cell
          style="margin-top: 10px"
          v-for="(item, index) in list"
          :key="index"
        >
          <div class="warn_item" @click="chooseInspectionWay(item)">
            <div>
              <div class="dep_sort">
                <div>{{ index + 1 }}、{{ item.PatrolRouteName }}</div>
              </div>

              <eagle-divider />
              <div class="dep_btm">
                <div class="btm_item" @click="edit(item)">
                  <img
                    src="@/assets/Images/AppIcon/icon_list_edit.png"
                    alt=""
                  />
                  <div class="mr-10">编辑</div>
                </div>
                <div class="btm_item" @click="del(item)">
                  <img src="@/assets/Images/AppIcon/icon_delete.png" alt="" />
                  <div>删除</div>
                </div>
              </div>
            </div>
            <!-- 弹出层 -->
            <van-dialog v-model="show" :showConfirmButton="false">
              <div class="dialog-content">
                <div class="dialog-title">提前几天生成</div>
                <div class="dialog-content-radio">
                  <span>您确定要结束该检查计划吗?</span>
                </div>
                <div class="dialog-bottom">
                  <div></div>
                  <div>
                    <span>取消</span>
                    <span class="complete-btn">仅结束计划</span>
                    <!-- <span class="complete-btn">结束计划及任务</span> -->
                  </div>
                </div>
              </div>
            </van-dialog>
          </div>
        </eagle-cell>
      </template>
    </eagle-page-list>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
      conditions: {},
      controller: "/DangerPatrolRoute",
      queryParams: {
        dataType: "List",
        keywords: "",
      },
      show: false,
    };
  },
  created() {
  },
  methods: {
    bindData(data) {
      this.list = [];
      if (data) {
        this.list = data;
      }
    },
    // 点击路线
    chooseInspectionWay(item) {
      this.$router.push({
        name: this.$route.params.path,
        params: {
          id: item.ID,
        },
      });
    },
    // 新增巡检路线
    add() {
      this.$router.push("/OtherDanger/AddInspectionWay");
    },
    // 编辑
    edit(item) {
      this.$router.push("/Danger/EditInspectionWay?id=" + item.ID);
    },
    del(item) {
      const _this = this;
      const id = item.ID;
      this.$dialog
        .confirm({
          title: "询问",
          message: "确定要删除该条巡检路线吗？",
        })
        .then(() => {
			_this.$axios
      			.get("/DangerPatrolRoute/Delete",{params:{ id: _this.id}})
				.then((res)=>{
					_this.getMyList();
				})
				.catch((err) => {
					console.log("err", err);
				});
        })
        .catch(() => {
          // on cancel
        });
    },
  },
};
</script>
<style lang="less"  scoped>
.risk {
  background-color: #e8f1f8;
  .info_search {
    padding: 10px;
    border-radius: 5px !important;
    .van-field__control {
      background-color: #ffffff !important;
    }
  }
}
</style>
<style lang="less" scoped>
.all_dep {
  background-color: #ffffff;
}
.warn_item {
  /*margin-bottom: 10px;*/
  // padding: 10px 0 10px 10px;
  border-radius: 5px;
  position: relative;
}
.warn_header {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 10px;
  .warn_tag {
    position: absolute;
    right: 0;
    top: 0;
    border-radius: 26.64rem 0 0 26.64rem;
  }
}
.dep_sort {
  // display: flex;
  // flex-wrap: wrap;
  // margin-bottom: 5px;
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
  }
}
.dep_btm {
  display: flex;
  justify-content: flex-end;
  font-size: 12px;
  .btm_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}

// 弹框
.dialog-content {
  position: relative;
  padding: 40px 0;

  .dialog-title,
  .dialog-bottom {
    width: 100%;
    position: fixed;
    left: 0;
    height: 40px;
    line-height: 40px;
    padding-left: 15px;
    font-size: 14px;
    background-color: #fff;
  }
  .dialog-title {
    top: 0;
  }
  .dialog-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    bottom: 0;
    padding: 0 15px;
    span {
      font-size: 14px;
      color: #666;
    }
    .complete-btn {
      color: rgb(0, 141, 101);
      margin-left: 20px;
    }
  }
  .dialog-content-radio {
    padding: 0 15px;
  }
}
</style>
